package com.xcity.game.skill.template;

import naga.x.game.template.Template;
import naga.x.game.template.TemplateException;
import naga.x.game.template.annotation.Excel;
import naga.x.util.NumberUtils;
import naga.x.util.StringUtils;

/**
 * 主角技能升级配置
 * @author yang.li
 *
 */
@Deprecated
@Excel(value = "skill.xlsx", sheet = 1)
public class PlayerSkillLevelUpTemplate extends Template {

	/** 消耗时间（秒） */
	protected String time;
	protected int[] times;

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public int getTotalTime(int level) {
		return level > 0 && level <= times.length ? times[level - 1] : Integer.MAX_VALUE;
	}
	
	public int getMaxLevel() {
		return times.length;
	}

	@Override
	public void validate() throws TemplateException {
		String[] strs = StringUtils.split(time, ";");
		times = new int[strs.length];
		for (int i = 0; i < strs.length; i++) {
			times[i] = NumberUtils.parseInt(StringUtils.trim(strs[i]));
			if (i > 0) {
				times[i] += times[i - 1]; // 累加
			}
		}
		time = null;
	}
}
